package Day14;

import java.rmi.UnmarshalException;

public class Girl {
    private String name;
    private int age;

    public Girl() {
    }

    public Girl(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) throws NameException {
        int len = name.length();
        if(len < 3 || len > 40){
            throw new NameException("姓名超出了限制");
        }
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) throws AgeException {
        if(age < 18 || age > 40){
            throw new AgeException("年龄超出了限制");
        }
        this.age = age;
    }
}
